﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Oracle.ManagedDataAccess.Client; 

namespace DbHelp
{
    public class OracleHelper : DbHelper
    {
        public OracleHelper()
        {
            OracleConnectionStringBuilder connSb = new OracleConnectionStringBuilder();
            connSb.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["OracleConnString"].ToString();
            string connStr = System.Configuration.ConfigurationManager.AppSettings["OracleConnString"].ToString();
            base.ProviderFactory = OracleClientFactory.Instance;
            base.ConnectionString = connStr;

            //System.Data.OracleClient.OracleConnection oracleCon = new System.Data.OracleClient.OracleConnection();
            ////oracleCon.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["OracleConnString"].ToString();
            ////base.Connection = oracleCon;
        }

        public string GetNewGuid()
        {
            string sql = "select sys_guid() from dual";
            byte[] bytes = base.ExecuteScalar(sql) as byte[];

            string ret = "";
            StringBuilder sb = new StringBuilder();
            foreach (byte item in bytes)
            {
                sb.Append(item > 15 ? Convert.ToString(item, 16) : '0' + Convert.ToString(item, 16));
            }
            ret = sb.ToString();
            return ret;

        }
    }
}
